package com.java.rabbitmq.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Woo_home
 * @create 2020/5/27 14:09
 */

@Configuration
public class RabbitMQConfig {

    // 声明交换机
    @Bean
    public DirectExchange emailExchange() {
        return new DirectExchange("EmailExchange");
    }

    // 声明队列
    @Bean
    public Queue emailQueue() {
        return new Queue("EmailQueue");
    }

    // 绑定交换机和队列
    @Bean
    public Binding bindEmail() {
        return BindingBuilder.bind(emailQueue())
                .to(emailExchange())
                .with("EmailRouting");
    }
}
